
function nop() { }

var midi = null;  // global MIDIAccess object
var output1 = null;

function onMIDISuccess(midiAccess) {
    console.log("MIDI ready!");
    midi = midiAccess;  // store in the global (in real usage, would probably keep in an object instance)
    listInputsAndOutputs(midi)
}

function onMIDIFailure(msg) {
    console.log("Failed to get MIDI access - " + msg);
}


function listInputsAndOutputs(midiAccess) {
    for (var entry of midiAccess.inputs) {
        var input = entry[1];
        console.log("Input port [type:'" + input.type + "'] id:'" + input.id +
            "' manufacturer:'" + input.manufacturer + "' name:'" + input.name +
            "' version:'" + input.version + "'");
    }

    const want = ""

    for (var entry2 of midiAccess.outputs) {
        var output = entry2[1];
        console.log("Output port [type:'" + output.type + "'] id:'" + output.id +
            "' manufacturer:'" + output.manufacturer + "' name:'" + output.name +
            "' version:'" + output.version + "'");
        if (output.name == want) {
            output1 = output;
        }
    }
}


nop(onMIDISuccess, onMIDIFailure)

// navigator.requestMIDIAccess().then(onMIDISuccess, onMIDIFailure);


////////////////////////////////////////////////////////////////////////////////

const state = {}

const getters = {}

const mutations = {}

const actions = {

    n() {
        nop(midi, output1)
    }

}



export default {
    name: "module_midi",
    namespaced: true,
    state, mutations, actions, getters
}
